#ifndef __TANK_OBJ_H__
#define __TANK_OBJ_H__

#include "impact/impactobj.h"
#include "./modelobj.h"

typedef void (Delegater::*OnTankModelImpactedFunc)();

class TankObj : public ModelObj<TankObj>, public ImpactObj
{
	MODEL_DEFINE
public:
	TankObj(int id, Point startPos, float rollRadian, float gunRadian, Color color);
	~TankObj();

	//operation
	void TurnRollToRadian(float dstRadian);
	void ReverseRollRadian(bool bPositive);
	void TurnGunToRadian(float dstRadian);
	void ReverseGunRadian(bool bPositive);
	void Go(bool bGo);
	void SetGoHeading(bool bAhead);
	void SetInvincible(bool bInvincible);
	void SetSpeed(float speed);
	void SetRollSpeed(float rollspeed);
	void SetGunSpeed(float gunspeed);

	//information
	float GetSpeed();
	float GetRollSpeed();
	float GetGunSpeed();
	float GetRollRadian();
	float GetGunRadian();
	bool GetHeading();
	bool GetGo();

	//impact model implement
	Point GetPos();
	float GetHeadingRadian();
	float GetRange();
	bool Impacted();

private:
	inline void CalcRender(float differTime);
	inline void CalcLimitPos();
	inline void CalcTankImpact();
	inline float CalcDifferRadian(float differObjRadian, float dstRadian, float curRadian);

	void OnRender(float differTime);
public:
	Event<OnTankModelImpactedFunc> OnImpacted;

private:
	//operation
	bool m_bInvincible;
	bool m_bGo;
	bool m_bAhead;
	bool m_bInivicibleVisible;

	bool m_bImpacted;
	float m_impactedTime;

	float m_invincibleTime;

	float m_dstRollRadian;
	float m_dstGunRadian;

	float m_curRollRadian;
	float m_curGunRadian;

	float m_speed;
	float m_rollspeed;
	float m_gunspeed;

	//information
	Point m_pos;

	static Point s_texOffset;
};

#endif